<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>优惠活动管理</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  #parse('/headFiles.html')
</head>
<body>
<div class="layui-fluid layui-form" wid100>
  <input type="hidden" name="id" value="$!{id}"/>
  <div class="layui-row">
    <div class="layui-col-sm8">
      <div class="layui-form-item">
        <label class="layui-form-label">活动标题</label>
        <div class="layui-input-block">
          <input type="text" name="title" placeholder="请输入活动标题" autocomplete="off" class="layui-input" value="$!{title}">
        </div>
      </div>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">所属代理</label>
    <div class="layui-input-block">
      <select id="userId" name="userId" class="layui-hide" lay-ignore>
        #if($userName)
        <option value="$!{userId}">$!{userName}</option>
        #end
      </select>
    </div>
  </div>
  <div class="layui-row">
    <div class="layui-col-sm6">
      <div class="layui-form-item">
        <label class="layui-form-label">活动开始时间</label>
        <div class="layui-input-block">
          <input type="text" id="startDate" name="startDate" placeholder="请输入活动开始时间" autocomplete="off"
                 class="layui-input" value="$!{utils.dateFormat($startDate,'yyyy-MM-dd')}">
        </div>
      </div>
    </div>
    <div class="layui-col-sm6">
      <div class="layui-form-item">
        <label class="layui-form-label">活动结束时间</label>
        <div class="layui-input-block">
          <input type="text" id="endDate" name="endDate" placeholder="请输入活动结束时间" autocomplete="off"
                 class="layui-input" value="$!{utils.dateFormat($endDate,'yyyy-MM-dd')}">
        </div>
      </div>
    </div>
  </div>
  <div class="layui-row">
    <div class="layui-col-sm6">
      <div class="layui-form-item">
        <label class="layui-form-label">活动类型</label>
        <div class="layui-input-block">
          <select name="type" lay-filter="type">
            #foreach($item in $typeList)
            <option value="$!{item.index()}" $!{utils.eq($item.index(),$type,'selected')}>$!{item.note()}</option>
            #end
          </select>
        </div>
      </div>
    </div>
    <div class="layui-col-sm6">
      <div class="layui-form-item">
        <label class="layui-form-label">最低消费金额</label>
        <div class="layui-input-block">
          <input type="text" name="minimumChargeStr" placeholder="请输入订单最低消费" autocomplete="off" class="layui-input" value="$!{minimumChargeStr}">
        </div>
      </div>
    </div>
  </div>
  <div class="layui-row">
    <div class="layui-col-sm6">
      <div class="layui-form-item">
        <label class="layui-form-label">优惠券类型</label>
        <div class="layui-input-block">
          <select name="couponType" lay-filter="couponType">
            #foreach($item in $couponTypeList)
            <option value="$!{item.index()}" $!{utils.eq($item.index(),$couponType,'selected')}>$!{item.note()}</option>
            #end
          </select>
        </div>
      </div>
    </div>
    <div class="layui-col-sm6">
      <div class="layui-form-item" id="couponDiscountPlan" style="display:${utils.eq($couponType,1,'block','none')};">
        <label class="layui-form-label">优惠折扣</label>
        <div class="layui-input-block">
          <input type="text" name="couponDiscount" placeholder="请输入优惠折扣" autocomplete="off" class="layui-input" value="$!{couponDiscount}">
        </div>
      </div>
      #if($couponType == 2 || $couponType == 10)
      <div class="layui-form-item" id="couponMoneyStrPlan" style="display:block;">
        <label class="layui-form-label">优惠金额</label>
        <div class="layui-input-block">
          <input type="text" name="couponMoneyStr" placeholder="请输入优惠金额" autocomplete="off" class="layui-input" value="$!{couponMoneyStr}">
        </div>
      </div>
      #else
      <div class="layui-form-item" id="couponMoneyStrPlan" style="display:none;">
        <label class="layui-form-label">优惠金额</label>
        <div class="layui-input-block">
          <input type="text" name="couponMoneyStr" placeholder="请输入优惠金额" autocomplete="off" class="layui-input" value="$!{couponMoneyStr}">
        </div>
      </div>
      #end
      <div class="layui-form-item" id="couponDayPlan" style="display:${utils.eq($couponType,3,'block','none')};">
        <label class="layui-form-label">优惠天数</label>
        <div class="layui-input-block">
          <input type="text" name="couponDay" placeholder="请输入免费天数" autocomplete="off" class="layui-input" value="$!{couponDay}">
        </div>
      </div>
    </div>
  </div>
  <div class="layui-row" id="useLimitPlan" style="display:${utils.eq($type,1,'blcok','none')};">
    <div class="layui-col-sm6">
      <div class="layui-form-item">
        <label class="layui-form-label">限制类型</label>
        <div class="layui-input-block">
          <select name="useLimit" lay-filter="useLimit">
            #foreach($item in $useLimitList)
            <option value="$!{item.index()}" $!{utils.eq($item.index(),$useLimit,'selected')}>$!{item.note()}</option>
            #end
          </select>
        </div>
      </div>
    </div>
    <div class="layui-col-sm6">
      <div class="layui-form-item" id="businessTypePlan" style="display:${utils.eq($useLimit,2,'blcok','none')};">
        <label class="layui-form-label">业务类型</label>
        <div class="layui-input-block">
          <select name="businessType">
            #foreach($item in $businessTypeList)
            <option value="$!{item.index()}" $!{utils.eq($item.index(),$businessType,'selected')}>$!{item.note()}</option>
            #end
          </select>
        </div>
      </div>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">活动描述</label>
    <div class="layui-input-block">
      <textarea name="note" placeholder="请输入活动描述" class="layui-textarea">$!{note}</textarea>
    </div>
  </div>
  <div class="layui-form-item layui-hide">
    <input type="button" lay-submit lay-filter="LAY-form-submit" id="LAY-form-submit" value="确认">
  </div>
</div>
#parse('/footFiles.html')
<script type="text/javascript">
layui.config({
  base: '$!{webRoot}/layuiadmin/'
  ,webRoot:'$!{webRoot}'
}).extend({
  index: 'lib/index'
}).use(['index', 'form', 'laydate'],function (){
  var $ = layui.$, form = layui.form, laydate = layui.laydate;

  laydate.render({
    elem: '#startDate'
    , type:'date'
    , range: false
  });

  laydate.render({
    elem: '#endDate'
    , type:'date'
    , range: false
  });

  $('#userId').select2({
    placeholder: "请选择归属代理",
    width: '300px',
    theme: 'bootstrap',
    allowClear : true,
    ajax: {
      url: '$!{webRoot}/agent/select.data',
      method: 'post',
      delay: 250,
      processResults: function (result) {
        if (result.code == 200) {
          return {
            pagination: {more: result.body.more},
            results: result.body.data || []
          };
        } else {
          return {results: []};
        }
      }
    }
  });

  form.on('select(type)', function(data){
    if(data.value == 2){
      $('#useLimitPlan').hide();
    }else {
      $('#useLimitPlan').show();
    }
  });

  form.on('select(useLimit)', function(data){
    if(data.value == 1){
      $('#businessTypePlan').hide();
    }else {
      $('#businessTypePlan').show();
    }
  });

  form.on('select(couponType)', function(data){
    if(data.value == 1){
      $('#couponMoneyStrPlan').hide();
      $('#couponDayPlan').hide();
      $('#couponDiscountPlan').show();
    }else if(data.value == 2){
      $('#couponDayPlan').hide();
      $('#couponDiscountPlan').hide();
      $('#couponMoneyStrPlan').show();
    }else if(data.value == 3 || data.value == 10){
      $('#couponMoneyStrPlan').hide();
      $('#couponDiscountPlan').hide();
      $('#couponDayPlan').show();
    }
  });

})
</script>
</body>
</html>